using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using NCS.Library;
using NCS.Library.Components;
using NCS.Module.CMS.Library;
using NCS.Module.CMS.Library.Providers;

namespace NCS.Module.CMS.Library.Contents
{
    public class ContentVersionController
	{
		private const string key = "NCS.Portal.CMS.Content";

        public static DataTable GetVersionByContentId(int contentId)
        {
            DataTable dt = DataAccessProvider.Instance().GetVersionByContentId(contentId);
            DataCaching data = new DataCaching();
            data.RemoveCache(key);
            return dt;
        }
        public static int AddContentVersion(ContentVersionInfo content)
        {
            int id = DataAccessProvider.Instance().AddContentVersion(content);
            DataCaching data = new DataCaching();
            data.RemoveCache(key);
            return id;
        }

        public static int Version_GetVersionUsedNow(int contentid)
        {
            int versionid = DataAccessProvider.Instance().Version_GetVersionUsedNow(contentid);
            DataCaching data = new DataCaching();
            data.RemoveCache(key);
            return versionid;
        }

        public static int Version_GetVersionRollback(int contentid)
        {
            int versionid = DataAccessProvider.Instance().Version_GetVersionRollback(contentid);
            DataCaching dc = new DataCaching();
            dc.RemoveCache(key);
            return versionid;
        }
        
        public static void UpdateContentVersion(ContentVersionInfo content)
        {
            DataAccessProvider.Instance().UpdateContentVersion(content);
            DataCaching data = new DataCaching();
            data.RemoveCache(key);
           
        }
        public static ContentVersionInfo GetInfo(int versionid)
        {
            ContentVersionInfo info;
            info = DataAccessProvider.Instance().GetInfoVersion(versionid);
            return info;
        }
        public static void DeleteContentVersion(int contentId)
        {
            DataAccessProvider.Instance().DeleteContentVersion(contentId);
            DataCaching data = new DataCaching();
            data.RemoveCache(key);
        }

        public static void Version_SetVersionRollback(int versionid, int versionbefore)
        {
            DataAccessProvider.Instance().Version_SetVersionRollback(versionid, versionbefore);
            DataCaching data = new DataCaching();
            data.RemoveCache(key);
        }

	}
}
